# 管理端-公眾內容管理接口
from flask import Blueprint, request, jsonify
from admin_route.basic import getAllDictionarys
from admin_route.public import getBottomInfo
from member_route.basic import getLocation, getNavList,getPolicyFilesList
from utils.tool import create_access_token, decrypt_AES_ECB, hash_psd, setResponse
import requests

member_main = Blueprint('member_main', __name__)

@member_main.route("/nav/list", methods=['GET'])
def getNavAll():
    res = getNavList(1)
    return res

# 政策文件

@member_main.route("/policyFiles/search", methods=['GET'])
def getPolicyFilesSearch():
    area = request.args.get('area')
    major1 = request.args.get('major1')
    major2 = request.args.get('major2')
    keyword = request.args.get('keyword')
    page = request.args.get('page', 1, type=int)  # 添加分页参数
    pageSize = request.args.get('pageSize', 10, type=int)  # 添加每页大小参数
    res = getPolicyFilesList(area, major1, major2, keyword, page, pageSize)  # 传递分页参数
    return res


@member_main.route("/bottomInfo", methods=['GET'])
def getBottomInfoById():
    id = request.args.get('id')
    res = getBottomInfo(id)
    return res


# 初始化获取字典
@member_main.route("/dictionary", methods=['GET'])
def getAllDictionaryList():
    res = getAllDictionarys()
    return res

@member_main.route("/baidu/location", methods=['GET'])
def getBaiduLocation():
    res = getLocation()
    return res


# 获取活动背景图片
@member_main.route("/backgroundImages/list", methods=['GET'])
def getActiveBackgroundImagesRoute():
    from member_route.basic import getActiveBackgroundImages
    res = getActiveBackgroundImages()
    return res
